<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>测试Restful</title>
    <script src="static/js/jquery-1.8.3.js"></script>
    <script>
        $(function () {
            $("#selectAllBtn").click(function () {
                $.ajax({
                    url:"aa/depts",
                    type:"GET",
                    dataType:"json",
                    success:function (res) {
                        console.log(res);
                    }
                });
            })
            $("#selectDeptById").click(function () {
                $.ajax({
                    url:"aa/depts/1",
                    type:"GET",
                    dataType:"json",
                    success:function (res) {
                        console.log(res);
                    }
                });
            });
            $("#saveDeptBtn").click(function () {
                var dname=$("#dname").val();
                $.ajax({
                    url:"aa/depts",
                    data:JSON.stringify({dname:dname}),
                    type:"POST",
                    dataType:"json",
                    contentType:"application/json",
                    success:function (res) {
                        console.log(res);
                    }
                });
            })
        })
    </script>
</head>
<body>
    部门名称:<input type="text" id="dname"><br>
    <button id="selectAllBtn">查询所有的部门</button>
    <button id="selectDeptById">按Id部门信息</button>
    <button id="saveDeptBtn">增加部门信息</button>
</body>
</html>
